<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="/WEB-INF/mytaglib.tld" prefix="mytag" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<fmt:setBundle basename="ua.races.raceBundle"/>

<html>
<head><title>Adding new Bet</title></head>
<body>

<c:set var="logoutText"><fmt:message key="logout"/></c:set>
<mytag:logout text="${logoutText}"/>

<c:set var="betTypeText"><fmt:message key="races.typeOfBet"/></c:set>
<c:set var="submitText"><fmt:message key="client.addNewBet.submit"/></c:set>
<c:set var="betValueText"><fmt:message key="races.betValue"/></c:set>
<c:set var="firstHorseText"><fmt:message key="races.firstHorse"/></c:set>
<c:set var="secondHorseText"><fmt:message key="races.secondHorse"/></c:set>
<c:set var="thirdHorseText"><fmt:message key="races.thirdHorse"/></c:set>

<jsp:useBean id="betType" type="ua.races.vo.BetType" scope="request"/>
<jsp:useBean id="fullRace" type="ua.races.relultObjects.FullRace" scope="request"/>

<mytag:stat history="5" align="center"/>

<table align="center" summary="" border="1" bgcolor="#fff0f5">

    <form action="postingToDb.do" method="POST">
        <tr>
            <td>${betTypeText}</td>
            <td><c:out value="${betType.betType}"/></td>
        </tr>
        <tr>
            <td>${firstHorseText}</td>
            <td>
                <select name="firstHorse">
                    <c:forEach var="horse" items="${fullRace.horses}">
                        <option>${horse.horseName}</option>
                    </c:forEach>
                </select>
            </td>
        </tr>
        <c:choose>
            <c:when test="${betType.betTypeId > 3}">
                <tr>
                    <td>${secondHorseText}</td>
                    <td>
                        <select name="secondHorse">
                            <c:forEach var="horse" items="${fullRace.horses}">
                                <option>${horse.horseName}</option>
                            </c:forEach>
                        </select>
                    </td>
                </tr>
            </c:when>
        </c:choose>
        <c:choose>
            <c:when test="${betType.betTypeId == 5}">
                <tr>
                    <td>${thirdHorseText}</td>
                    <td>
                        <select name="thirdHorse">
                            <c:forEach var="horse" items="${fullRace.horses}">
                                <option>${horse.horseName}</option>
                            </c:forEach>
                        </select>
                    </td>
                </tr>
            </c:when>
        </c:choose>

        <tr>
            <td>${betValueText}</td>
            <td><input type="text" name="betValue"></td>
        </tr>
        <input type="hidden" name="betTypeId" value="${betType.betTypeId}"/>
        <input type="hidden" name="raceId" value="${fullRace.race.raceId}"/>
        <tr>
            <td><input name="back" type="button" value="<--back"
                       onclick="top.location.href='addNewBet.do'"/></td>
            <td><input type="submit" value="${submitText}"/></td>

        </tr>
    </form>

</table>

</body>
</html>